﻿<UserControl 
  x:Class="CrackNET.InjectedViewer.View.ElementTreeExplorer.ElementTreeExplorerView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  xmlns:vw="clr-namespace:CrackNET.InjectedViewer.View.ElementTreeExplorer"
  xmlns:vm="clr-namespace:CrackNET.InjectedViewer.ViewModel.ElementTreeExplorer"
  >
  <Grid Background="{DynamicResource PrimaryBackgroundBrush}">
    <Grid.Resources>
      <Style TargetType="{x:Type TreeViewItem}">
        <Style.Resources>
          <Style TargetType="{x:Type ToolTip}">
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                  <Grid Width="200" Height="200">
                    <Rectangle Fill="{TemplateBinding Content}" RadiusX="10" RadiusY="10" Margin="10"/>
                    <Grid.Effect>
                      <DropShadowEffect />
                    </Grid.Effect>
                  </Grid>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </Style.Resources>
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
        <Setter Property="Background" Value="{Binding TreeBackgroundBrush}"/>
        <Setter Property="ToolTip" Value="{Binding VisualBrush}" />
      </Style>
    </Grid.Resources>

    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TreeView 
      x:Name="Tree" 
      Grid.Row="0"
      HorizontalAlignment="Stretch"
      ItemsSource="{Binding Filtered}"
      Margin="2,0,2,0" 
      VirtualizingStackPanel.IsVirtualizing="False"
      >
      <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type vm:ElementTreeItem}" ItemsSource="{Binding Children}">
          <TextBlock Text="{Binding}" HorizontalAlignment="Stretch" Background="Transparent"/>
        </HierarchicalDataTemplate>
      </TreeView.Resources>
    </TreeView>

    <Border Grid.Row="1" Margin="0,4,0,0">
      <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
          <Button Content="Navigate To" Width="80" />
          <Button Content="Cancel" Width="80" Margin="6,0,0,0" Command="{Binding Path=CloseCommand, Mode=OneTime}" />
        </StackPanel>
      </Grid>
    </Border>
  </Grid>
</UserControl>